<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>create (MywikiController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File app/controllers/mywiki_controller.rb, line 87</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
        <span class="ruby-ivar">@mywiki</span> = <span class="ruby-constant">Mywiki</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:mywiki</span>])
        <span class="ruby-identifier">get_user</span>
        <span class="ruby-ivar">@mywiki</span>.<span class="ruby-identifier">userid</span> = <span class="ruby-ivar">@id</span>;
        <span class="ruby-identifier">p</span> <span class="ruby-ivar">@mywiki</span>
        <span class="ruby-ivar">@title</span> = <span class="ruby-ivar">@mywiki</span>.<span class="ruby-identifier">title</span>
        <span class="ruby-identifier">p</span> <span class="ruby-ivar">@title</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@title</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@title</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
            <span class="ruby-identifier">p</span> <span class="ruby-value str">'in if....'</span>
                <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:error</span>] = <span class="ruby-value str">'Wiki page could not be created with empty title!'</span>            
        <span class="ruby-keyword kw">else</span>
            <span class="ruby-identifier">p</span> <span class="ruby-value str">'in else...'</span>
                <span class="ruby-ivar">@exist_wiki</span> = <span class="ruby-constant">Mywiki</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;title = '&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@title</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot;'&quot;</span> );
                <span class="ruby-identifier">p</span> <span class="ruby-ivar">@exist_wiki</span>
                <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@exist_wiki</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@exist_wiki</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
                    <span class="ruby-identifier">p</span> <span class="ruby-value str">'saving'</span>
                        <span class="ruby-ivar">@mywiki</span>.<span class="ruby-identifier">save</span>         
                <span class="ruby-keyword kw">else</span>
                        <span class="ruby-identifier">p</span> <span class="ruby-value str">'Error'</span>
                        <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:error</span>] = <span class="ruby-value str">'Wiki page '</span><span class="ruby-operator">+</span><span class="ruby-ivar">@title</span><span class="ruby-operator">+</span><span class="ruby-value str">' already exists!'</span>               
                <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span>
    <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:view</span>, <span class="ruby-identifier">:f</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@title</span>  
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>